<?php

namespace Tests\Feature;

use App\DataProviders\AirportDataProvider;
use App\DataProviders\AirportDataProviderInterface;
use Tests\TestCase;

class AirportsDataProviderTest extends TestCase
{

    private AirportDataProviderInterface $dataProvider;

    public function setUp(): void
    {
        $this->dataProvider = new AirportDataProvider(
            'https://raw.githubusercontent.com/NemoTravel/nemo.travel.geodata/master/airports.json'
        );
    }

    public function testAirportsDataExists()
    {
        $result = $this->dataProvider->fetchAirportsData();
        $this->assertIsArray($result);

        foreach ($result as $airport) {
            $this->assertArrayHasKey('code', $airport);
            $this->assertArrayHasKey('country', $airport);
            $this->assertArrayHasKey('cityName', $airport);
            $this->assertArrayHasKey('en', $airport['cityName']);
            $this->assertArrayHasKey('ru', $airport['cityName']);
        }
    }
}
